package com.etc.test;

import java.util.List;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.etc.entity.HistoryInfo;
import com.etc.entity.MedicalHistory;
import com.etc.entity.Patient;
import com.etc.entity.Prescription;
import com.etc.service.PatientService;

/**
 * 病人测试类
 * 
 * @author 小白
 *
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:applicationContext.xml", "classpath:mybatis-config.xml" })
public class PatientTestJUnit {
	@Autowired
	private PatientService patientService;
	
	/**
	 * 查询单个病人对象测试方法
	 */
	@Test
	public void getPatientById() {
		Patient patient = patientService.selPatientById("15268794562");
		System.out.println(patient);

	}
	
	@Test
	public void getPatient() {
		List<Patient> patient= patientService.selectPatient();
		patient.forEach(System.out::println);
		
	}
	/**
	 * 医生查询病人信息
	 */
	@Test
	public void getByTel(){
		List<MedicalHistory> list = patientService.selectByPatientTel("15268794562");
		list.forEach(System.out::println);
	}
	
	@Test
	public void getHistoryInfo() {
		List<HistoryInfo> h= patientService.selPatientInfoByTel("15268794562",0,2);
		System.out.println(h.size());
	}
	/**
	 * 医生查看药方测试
	 */
	@Test
	public void getPrescription(){
		List<Prescription> list = patientService.getPrescription(1);
		list.forEach(System.out::println);
	}
	@Test
	public void getMedicineByDate() {
		List<HistoryInfo> list = patientService.selMedicineByDate("15268794562", "2018-11-14 18:10:26");
		System.out.println(list);
	}
	
	@Test
	public void insert() {
		Patient patient = new Patient();
		patient.setPatientaddress("1");
		patient.setPatientage(1);
		
		patient.setPatientname("1");
		patient.setPatientnation("1");
		patient.setPatientrelationname("1");
		patient.setPatientrelationtel("1");
		patient.setPatientsex("1");
		patient.setPatienttel("1");
		patient.setPatientidentity("1");
		boolean flag=patientService.insert(patient);
		System.out.println(flag);
	}

}
